package com.leps.nq.sys.controller;

import com.leps.nq.common.vo.PageVo;
import com.leps.nq.common.vo.R;
import com.leps.nq.common.vo.RBuilder;
import com.leps.nq.sys.entity.SysOperLog;
import com.leps.nq.sys.service.ISysOperLogService;
import com.leps.nq.sys.vo.OperLogQueryModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 操作日志记录 前端控制器
 * </p>
 *
 * @author hex
 * @since 2022-05-20
 */
@RestController
@RequestMapping("/sys/sys-oper-log")
@Api(tags = "系统操作日志管理")
public class SysOperLogController {
    @Autowired
    ISysOperLogService operLogService;

    @GetMapping
    @ApiOperation("操作日志列表")
    public R<PageVo> list(OperLogQueryModel queryModel) {
        PageVo<SysOperLog> vo = this.operLogService.listByQueryModel(queryModel);
        return RBuilder.ok(vo);
    }

    @DeleteMapping
    @ApiOperation("删除操作日志")
    public R remove(@RequestBody Long[] id) {
        this.operLogService.deleteByIds(id);
        return RBuilder.ok();
    }

    @DeleteMapping("/clear")
    @ApiOperation("清空操作日志")
    public R clear() {
        this.operLogService.clear();
        return RBuilder.ok();
    }
}
